package com.fare.taluo.core.domain.queue.warn;

import java.util.List;

import com.fare.taluo.core.domain.analyse.alert.FreightPriceAnalyseAlertConfigEntity;
import com.fare.taluo.fetl.domain.entity.FreightPriceEntity;
import com.fare.taluo.util.DateUtils;

public class SpreadWarnStrategy {
	private FreightPriceAnalyseAlertConfigEntity config;
	private List<FreightPriceEntity> list;
	public SpreadWarnStrategy(FreightPriceAnalyseAlertConfigEntity config,List<FreightPriceEntity> list) {
		super();
		this.config = config;
		this.list = list;
	}
	
	public String buildEmailContent(){
		StringBuffer buffer = new StringBuffer(); 
		buffer.append(DateUtils.formatDay(config.getFlightDate(), "yyyy-MM-dd")+"起飞的");
		buffer.append("<span style=\"color: #ff0000\">"+config.getFlightNo()+"</span>连续<span style=\"color: #ff0000\">"+config.getTriggerCondition()+"</span>天的最低价和");
		buffer.append("<span style=\"color: #ff0000\">"+config.getContrastSource()+"</span>价差大于<span style=\"color: #ff0000\">"+config.getTriggerConditionSpread()+"%</span><br>");
		buffer.append("对应的记录是<br>");
		for (FreightPriceEntity entity : list) {
			buffer.append("抓取时间为<span style=\"color: #ff0000\">"+DateUtils.formatDay(entity.getGrabDate(), "yyyy-MM-dd hh:mm")+"</span>的<span style=\"color: #ff0000\">"+entity.getGrabChannel()+"的"+entity.getFlightNo()+"</span>最低价格是<span style=\"color: #ff0000\">"+entity.getPrice()+"  </span>对应的<span style=\"color: #ff0000\">"+entity.getCompareGrabChannel()+
					"</span>的最低价格是<span style=\"color: #ff0000\">"+entity.getComparePrice()+" </span>价差是<span style=\"color: #ff0000\">"+entity.getPriceRatio()*100+"%</span><br>");
		}
		
		return buffer.toString();
	}
	
	
	
	
	
	
}
